package com.example.check_oa.controller;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.example.check_oa.model.mapper.HolidayApMapper;
import com.example.comment_oa.pojos.attendance.HolidayAp;
import com.example.check_oa.model.service.HolidayTypeService;
import com.example.comment_oa.response.AjaxResponse;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import javax.annotation.Resource;

@RestController
@RequestMapping("checkOa/holiday")
@CrossOrigin
public class HolidayController {
    @Resource
    HolidayApMapper holidayApMapper;
    @Resource
    HolidayTypeService holidayTypeService;

//    //请假list集合
//    @PostMapping("query/{day}/{userNo}")
//    public AjaxResponse query(@PathVariable String day,@PathVariable String userNo){
//        QueryWrapper<HolidayAp> wrapper=new QueryWrapper<>();
//        wrapper.eq("HO_STATE",1);
//        wrapper.eq("USER_HO",userNo);
//        wrapper.like("HO_AP_TIME",day);
//        return AjaxResponse.success(holidayApMapper.selectList(wrapper));
//    }

    @PostMapping("add")
    public AjaxResponse add(HolidayAp holidayAp, MultipartFile file){
        System.out.println(holidayAp);
        return AjaxResponse.success(holidayTypeService.add(holidayAp,file));
    }

    @PostMapping("selectByWate/{water}")
    public AjaxResponse selectByWate(@PathVariable("water")String water){
        return AjaxResponse.success(holidayApMapper.selectHoWater(water));
    }

}
